package com.party.core.model.wechat;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author wei.li
 * @version 2016/8/2 0002
 */
public enum WechatMessageType {

    FOCUS_REPLY(1,"被关注回复"),

    AUTO_REPLY(2,"自动回复"),

    KEYWORD_REPLY(3,"关键字回复"),

    EVENT_REPLY(4, "事件回复");

    //状态码
    private Integer code;

    //状态值
    private String value;



    /**
     * 根据代码获取枚举值
     * @param code 代码
     * @return 状态值
     */
    public static String getValue(Integer code){
        for (WechatMessageType wecahtMessageType : WechatMessageType.values()){
            if (wecahtMessageType.getCode().equals(code)){
                return wecahtMessageType.getValue();
            }
        }
        return null;
    }


    /**
     * 枚举类型转换为map
     * @return 转换后的map
     */
    public static Map<Integer,String> convertMap(){
        Map<Integer,String> map = Maps.newHashMap();
        for (WechatMessageType wecahtMessageType : WechatMessageType.values()){
            map.put(wecahtMessageType.getCode(),wecahtMessageType.getValue());
        }
        return map;
    }


    WechatMessageType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
